import { queryChannel,queryChannelRecord,playbackStart } from './service';
const Model = {
  namespace: 'cameraHistory',
  state: {
    channelList: [],
    recordList: [],
  },
  effects: {
    *fetch({ payload }, { call, put }) {
      const response = yield call(queryChannel, payload);
      yield put({
        type: 'queryList',
        payload: Array.isArray(response.data) ? response.data : [],
      });
    },
    *channelRecord({ payload }, { call, put }) {
      const response = yield call(queryChannelRecord, payload.deviceId,payload.channelId,payload.day);
      yield put({
        type: 'queryChannelRecord',
        payload: Array.isArray(response.recordList) ? response.recordList : [],
      });
    },
  },
  reducers: {
    queryList(state, action) {
      return { ...state, channelList: action.payload };
    },
    queryChannelRecord(state, action) {
      return { ...state, recordList: action.payload };
    },
  },
};
export default Model;
